﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using WarningAndMonitingSystem.Models;

namespace WarningAndMonitingSystem.Common
{
    public class DataContextUtil
    {
        public static event Action UpdateAlarmList;

        private static List<AlarmLogInfo> alarmLogInfos = new List<AlarmLogInfo>();

        public static void AddAlarmLogInfo(AlarmLogInfo alarmLogInfo)
        {
            alarmLogInfos.Add(alarmLogInfo);
        }

        public static List<AlarmLogInfo> GetAlarmLogInfos(Func<AlarmLogInfo,bool> expression)
        {
            return alarmLogInfos.Where(expression).ToList();
        }

        public static List<AlarmLogInfo> GetAlarmLogInfos()
        {
            return alarmLogInfos;
        }

        public static void UpdateDgView()
        {
            UpdateAlarmList?.Invoke();
        }
    }
}
